<div id="bd">
  <div id="yui-main" class="content">
    <div class="yui-b first">
      <b class="btop"><b></b></b>
      {if $user->cat_username}
      <div class="resulthead"><h3>{translate text='Your Checked Out Items'}</h3></div>
      <div class="page">
        {if $transList}
        {if $renewForm == "true"}
        <form name="renewall" action="{$url|escape}/MyResearch/CheckedOut" method="POST" id="renewall"> 
          <div>
            <div class="renewall">
              {foreach from=$transList item=system key=syskey}
                {foreach from=$system item=resource name="recordLoop"}
                  {if $resource.ils_details.renewable}
                    {if $resource.ils_details.renew_details}<input type="hidden" name="renew[]" value="{$resource.ils_details.renew_details}" />{/if}
                  {/if}
                {/foreach}
              {/foreach}
              <input type="submit" name="submitall" value="{translate text='Renew All Items'}" />
            </div> 
          </div>
        </form>

        <form name="renewals" action="{$url}/MyResearch/CheckedOut" method="POST" id="renewals">
        {/if}
         
        {foreach from=$transList item=system key=syskey name="systemLoop"}
        <h4>{translate text=$syskey}</h4>
        <ul class="filters">
        {foreach from=$system item=resource name="recordLoop"}
          {if ($smarty.foreach.recordLoop.iteration % 2) == 0}
          <li class="result alt">
          {else}
          <li class="result">
          {/if}
            <div class="yui-ge">
              <div class="yui-u first">
                <img src="{$path}/bookcover.php?isn={$resource.isbn|@formatISBN}&amp;size=small" class="alignleft">

                <div class="resultitem">
                  <a href="{$url}/Record/{$resource.id|escape:"url"}" class="title">{$resource.title|escape}</a><br>
                  {if $resource.author}
                  {translate text='by'}: <a href="{$url}/Author/Home?author={$resource.author|escape:"url"}">{$resource.author|escape}</a><br>
                  {/if}
                  {if $resource.tags}
                  {translate text='Your Tags'}:
                  {foreach from=$resource.tags item=tag name=tagLoop}
                    <a href="{$url}/Search/Results?tag={$tag->tag|escape:"url"}">{$tag->tag|escape}</a>{if !$smarty.foreach.tagLoop.last},{/if}
                  {/foreach}
                  <br />
                  {/if}
                  {if $resource.notes}
                  {translate text='Notes'}: {$resource.notes|escape}<br>
                  {/if}

                  {if is_array($resource.format)}
                    {foreach from=$resource.format item=format}
                      <span class="iconlabel {$format|lower|regex_replace:"/[^a-z0-9]/":""}">{translate text=$format}</span>
                    {/foreach}
                  {else}
                    <span class="iconlabel {$resource.format|lower|regex_replace:"/[^a-z0-9]/":""}">{translate text=$resource.format}</span>
                  {/if}

                  <br />
                    
                  {* Make sure a renewResult is available *} 
                  {if $renewResult}
                    {* Check if a renew attempt has been made *}
                    {if in_array($resource.ils_details.item_id, $renewArray)}
                      {* Loop Through renewmsg and display details if there is a match to the current item *}
                        {foreach from=$renewResult item=item_info key=item_id}
                          {if $item_id == $resource.ils_details.item_id && $item_info.system == $syskey}
                            {if $item_info.success =="true"}
                              <strong>{translate text='Due Date'}: {$item_info.new_date}</strong>
                              <br />
                              {translate text='renew_success'}
                            {else}
                            <strong>{translate text='Due Date'}: {$resource.ils_details.duedate}</strong>
                            <br />
                            {translate text='renew_fail'}{if $item_info.sysmessage}: {$item_info.sysmessage}{/if} 
                          {/if}
                        {/if}
                      {/foreach}
                    {else}
                      <strong>{translate text='Due Date'}: {$resource.ils_details.duedate}</strong>
                    {/if}
                  {else}
                  <strong>{translate text='Due Date'}: {$resource.ils_details.duedate}</strong>
                  {/if}
                   
                  <br />
                  {if $resource.ils_details.message}
                    <span class="info">{translate text=$resource.ils_details.message}</span>
                    <br />                   
                  {/if}
                  {if $resource.ils_details.renewable}  
                    {if $resource.ils_details.renew_details}
                      {translate text='Renew Item'}: <input type="checkbox" name="renew[]" value="{$resource.ils_details.renew_details}" class="renewcheck" />
                    {elseif $resource.ils_details.renew_link}
                      <a href="{$resource.ils_details.renew_link|escape}">{translate text='Renew Item'}</a> 
                    {/if}
                  {/if}
                </div>
              </div>
            </div>
          </li>
        {/foreach}
        </ul>
        <br class="clear" />
        {/foreach}
          

        {if $renewForm == "true"}
          <input type="submit" value="{translate text="Renew Selected Items"}" />
        </form>
        {/if}
       
        {else}
        {translate text='You do not have any items checked out'}.
        {/if}
      </div>
      {else}
        <div class="page">
          {include file="MyResearch/catalog-login.tpl"}
        </div>
      {/if}

    <b class="bbot"><b></b></b>
    </div>
  </div>

  {include file="MyResearch/menu.tpl"}

</div>
